Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Validation): Add new Validation components #351

Merged
merged 9 commits into from
Jul 31, 2020
Merged

Conversation

haworku
Copy link
Contributor

@haworku haworku commented Jul 27, 2020

Summary

Add ValidationChecklist and ValidationItem components. See https://designsystem.digital.gov/components/form-controls/#validation

Related Issues or PRs

#80

@haworku haworku added the type: feature New feature or request label Jul 27, 2020
<ValidationChecklist id="validate-password">
<ValidationItem
id="required"
isValid={values.password.length > 0}>
Copy link
Contributor Author

@haworku haworku Jul 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally isValid would use different logic than this - just did something simple for the example. Open to other ways to do this. The alternative I found was writing a long validate function that digs inside yup's error object and manually updated bits of component state. It seemed like overkill for this example.

react hook form seems to handle this better than formik... couldn't find a similar formik util.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh I see, yeah I wouldn't worry too much about this since it's really a Formik implementation detail..

suzubara
suzubara previously approved these changes Jul 29, 2020
Copy link
Contributor

@suzubara suzubara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the implementation of these components, and I love how thorough the examples and tests are! 🚀

<ValidationChecklist id="validate-password">
<ValidationItem
id="required"
isValid={values.password.length > 0}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh I see, yeah I wouldn't worry too much about this since it's really a Formik implementation detail..

export default {
title: 'Forms/Validation',
component: ValidationChecklist,
ValidationItem,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL you can also have subcomponents if you like that idea

Copy link
Contributor Author

@haworku haworku Jul 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahobson Thanks for sharing! I'm definitely going to use this. Also seems useful for a bunch of our other stories, I may do some cleanup later this week.

Copy link
Contributor

@ahobson ahobson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@haworku haworku merged commit 2b2369a into main Jul 31, 2020
@haworku haworku deleted the hw-validation-80 branch July 31, 2020 14:03
@haworku haworku mentioned this pull request Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants